All Questions
125 questions
3votes
2answers
95views
Optimizing a Function to Check Pronic Numbers in JavaScript
I've written a function in JavaScript to check whether a given number is a Pronic number. A Pronic number, also known as an oblong number, rectangular number, or ...
1vote
2answers
1kviews
Leetcode 55. Jump Game solution
I was working on Jump Game problem on leetcode Question You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ...
2votes
1answer
257views
Leetcode problem: minimum removal to make valid parentheses
I was working on this problem on leetcode Question Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and ...
3votes
1answer
341views
Algorithm Challenge: Fuzzy Search
I recently took part in an algorithm challenge to create a Fuzzy search with the following criteria: Given a set array, create a function that receives one argument and returns a new array containing ...
2votes
3answers
415views
Leetcode First Unique Character in a String code optimisation
I was working on First Unique Character in a String Question Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: ...
2votes
3answers
1kviews
Find the 'n' most frequent words in a text, aka word frequency
I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name. The ...
1vote
2answers
343views
Leetcode 377. Combination Sum IV Javascript Memoization attempt
Problem Statement ...
1vote
1answer
524views
Cheapest flights within k stops algorithm in JavaScript
The problem: There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is ...
2votes
1answer
227views
Leetcode 3 sum code optimisation
I was working on 3sum problem on leetcode Question Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the ...
3votes
3answers
348views
Project Euler 50: Consecutive prime sum
I just finished solving Project Euler's 50th problem, but it's awfully slow. I'd like to hear your thoughts on my code's efficiency and practices. Problem Statement The prime 41, can be written as the ...
3votes
1answer
696views
Optimizing code solution for Palindrome Index-Hackerrank
I submitted my solution for palindrome Index coding challenge but I get "test cases terminated due to time out error". My code is working and so I don't know what else to do to optimize it. Please ...
2votes
1answer
5kviews
Comparing version numbers with JavaScript
I have written a function that compares two version number strings (e.g. 1.2.0 and 1.2.2) and return 1 if the first string is greater, ...
2votes
1answer
926views
Codewars: Prime Streaming (PG-13)
I'm timing out on Codewars' Prime Streaming kata. Below is my code: ...
2votes
1answer
1kviews
Codewars: Pick peaks
Pick peaks Wrote my "hello world" on Thursday, so definitely a beginner. I know some Python, so not a novice to programming in general. Question For example, the array ...
3votes
1answer
2kviews
Maze path finder using Depth-First Search algorithm
I'm trying to resolve this kata from CodeWars. Kata exercise You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). ...